package com.techsen.tsweb.sys.web.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.techsen.tsweb.core.domain.JsonResult;
import com.techsen.tsweb.sys.domain.Dept;
import com.techsen.tsweb.sys.service.DeptService;

@Controller
@RequestMapping("/sys/dept")
public class DeptController {
    
    @Resource
    private DeptService deptService;
    
    /**
     * 查看部门
     */
    @RequestMapping("/orgid/{orgId}")
    public String view(@PathVariable("orgId") String orgId, Model model) {
        Dept dept = this.deptService.getOneByEntity(new Dept().setOrgId(orgId));
        model.addAttribute("dept", dept);
        return "sys/dept-view";
    }

    /**
     * 修改部门
     */
    @RequestMapping("/update")
    public @ResponseBody JsonResult update(Dept dept) {
        this.deptService.update(dept);
        return new JsonResult(dept);
    }

}
